{template 'common/header'}
{php echo $this -> set_tabbar($action);}
<!--地图begin-->
<!--<script src="http://api.map.baidu.com/api?key=24ffad3855e675265336a4cfb46d32b4&v=1.1&services=true" type="text/javascript"></script>-->
<!--<script src="http://api.map.baidu.com/getscript?v=1.1&ak=&services=true&t={TIMESTAP}" type="text/javascript" ></script>-->
<!--<link href="http://api.map.baidu.com/res/11/bmap.css" rel="stylesheet" type="text/css">-->
<!--地图end-->
<div class="main">
        <form action="" method="post" onsubmit="return check();" class="form-horizontal form" enctype="multipart/form-data">
        <h4>{$title} - <a href="{php echo create_url('site/module', array('do' => 'SetRule', 'name' => 'icard'));}" style="font-size:0.8em">入口设置</a></h4>
		<table class="tb">
			<tr>
				<th><label for="">商家名称</label></th>
				<td>
                    <input type="text" name="title" value="{$reply['title']}" id="title" class="span7" />
				</td>
			</tr>
            <tr>
                <th><label for="">商家Logo</label></th>
                <td>
                    <div id="" class="uneditable-input reply-edit-cover">
                        <div class="detail">
                            <span class="pull-right">大图片建议尺寸：200像素 * 200像素</span>
                            <input type="button" id="btnlogo" fieldname="hidlogo" class="btn btn-mini reply-edit-cover-upload" value="<i class='icon-upload-alt'></i> 上传" style="" />
                            <button type="button" class="btn btn-mini reply-news-edit-cover-remove" id="upload-delete" onclick="doDeleteItemImage(this, 'hidlogo')" style="{if empty($reply['logo'])} display:none;{/if}"><i class="icon-remove"></i> 删除</button>
                        </div>
                        {if !empty($reply['logo'])}
                            <input type="hidden" name="hidlogo-old" value="{$reply['logo']}">
                            <div id="upload-file-view" class="upload-view" style="width: 100px;">
                                <input type="hidden" id="hidlogo" name="hidlogo" value="{$reply[logo]}">
                                <img width="100" src="{$_W['attachurl']}{$reply['logo']}">
                            </div>
                        {else}
                            <div id="upload-file-view" style="width: 100px;"></div>
                        {/if}
                    </div>
                </td>
            </tr>
            <tr>
                <th><label for="">封面消息</label></th>
                <td>
                    <input type="text" name="info" id="info" value="{if empty($reply)}微时代会员卡，方便携带收藏，永不挂失{else}{$reply['info']}{/if}" class="span7" >
                </td>
            </tr>

            <tr>
                <th><label for="">商家类别</label></th>
                <td>
                    <select name="category_f" id="category_f" class="span2"></select>
                    <select name="category_s" id="category_s" class="span2"></select>
                    <script type="text/javascript" src="./source/modules/icard/template/js/category.js"></script>
                    <script type="text/javascript">
                        var category_f = "{$reply['category_f']}";
                        var category_s = "{$reply['category_s']}";
                    </script>
                    <script type="text/javascript">
                        new CS("category_f", "category_s", category_f, category_s, '美食-1$本帮江浙菜-11,川菜-12,粤菜-13,湘菜-14,贵州菜-15,东北菜-16,台湾菜-17,新疆/清真菜-18,西北菜-19,素菜-20,火锅-21,自助餐-22,小吃快餐-23,日本-24,韩国料理-25,东南亚菜-26,西餐-27,面包甜点-28,其他-29#休闲娱乐-2$密室-30,咖啡厅-31,酒吧-32,茶馆-33,KTV-34,电影院-35,文化艺术-36,景点/郊游-37,公园-38,足疗按摩-39,洗浴-40,游乐游艺-41,桌球-42,桌面游戏-43,DIY手工坊-44,其他-45#购物-3$综合商场-46,食品茶酒-47,服饰鞋包-48,珠宝饰品-49,化妆品-50,运动户外-51,亲子购物-52,品牌折扣店-53,数码家电-54,家居建材-55,特色集市-56,书店-57,花店-58,眼镜店-59,超市/便利店-60,药店-61,其他-62#丽人-4$美发-63,美容/SPA-64,化妆品-65,瘦身纤体-66,美甲-67,瑜伽-68,舞蹈-69,个性写真-70,整形-71,齿科-72,其他-73#结婚-5$婚纱摄影-74,婚宴-75,婚戒首饰-76,婚纱礼服-77,婚庆公司-78,彩妆造型-79,司仪主持-80,婚礼跟拍-81,婚车租赁-82,婚礼小商品-83,婚房装修-84,其他-85#亲子-6$幼儿教育-86,亲子摄影-87,亲子游乐-88,亲子购物-89,孕产护理-90,其他-91#运动健身-7$游泳馆-92,羽毛球馆-93,健身中心-94,瑜伽-95,舞蹈-96,篮球场-97,网球场-98,足球场-99,高尔夫场-100,保龄球馆-101,桌球馆-102,乒乓球馆-103,武术场馆-104,体育场馆-105,其他-106#酒店-8$五星级酒店-107,四星级酒店-108,三星级酒店-109,经济型酒店-110,公寓式酒店-111,精品酒店-112,青年旅舍-113,度假村-114,其他-115#爱车-9$4S店/汽车销售-116,汽车保险-117,维修保养-118,配件/车饰-119,驾校-120,汽车租赁-121,停车场-122,加油站-123,其他-124#生活服务-10$旅行社-125,培训-126,室内装潢-127,宠物-128,齿科-129,快照/冲印-130,家政-131,银行-132,学校-133,团购网站-134,其他-135#其他-11$其他-136');
                    </script>
                </td>
            </tr>
			<tr>
				<th><label for="">商家简介</label></th>
				<td>
                    <textarea style="height:200px; width:535px;" class="span7 richtext-clone" name="content" cols="70" id="reply-add-text">{$reply['content']}</textarea>
				</td>
			</tr>
			<tr>
				<th><label for="">电话</label></th>
				<td>
                    <input type="text" name="tel" id="tel" value="{$reply['tel']}" class="span7">
				</td>
			</tr>
            <tr>
                <th><label for="">商家所在地区</label></th>
                <td>
                    <select name="location_p" id="location_p" class="location span2"></select>
                    <select name="location_c" id="location_c" class="location span2"></select>
                    <select name="location_a" id="location_a" class="location span2"></select>
                    <script type="text/javascript" src="./source/modules/icard/template/js/region_select.js"></script>
                    <script type="text/javascript">
                        var location_p = "{if !empty($reply['location_p'])}{$reply['location_p']}{else}广东省{/if}";
                        var location_c = "{if !empty($reply['location_c'])}{$reply['location_c']}{else}汕头市{/if}";
                        var location_a = "{if !empty($reply['location_a'])}{$reply['location_a']}{else}龙湖区{/if}";
                        new PCAS("location_p", "location_c", "location_a", location_p, location_c, location_a);
                    </script>
                </td>
            </tr>
            <tr>
                <th><label for="">地址</label></th>
                <td>
                    <input type="text" name="address" id="address" value="{$reply['address']}" class="span7" >
                </td>
            </tr>
            <tr>
                <th><label for="">经纬度</label></th>
                <td>
                    <div class="input-append">
                        <input type="text" id="place" class="input-xlarge valid" name="place" value="汕头市龙湖区长平路127号" data-rule-required="true">
                        <button class="btn" type="button" id="positioning" onclick="bmap.searchMapByAddress($('#place').val())">搜索</button>
                    </div>
                    <span class="maroon" style="color: #f30;margin-left: 5px;">注意：这个只是模糊定位，准确位置请地图上标注!</span>
                    <div id="l-map" style="overflow: hidden; position: relative; z-index: 0; background-image: url(http://api.map.baidu.com/images/bg.png);width: 500px; height: 300px;margin-top: 10px; color: rgb(0, 0, 0); text-align: left;"></div>
                    <div id="r-result">
                        <input type="text" id="lat" name="lat"> <input type="text" id="lng" name="lng">
                    </div>
                </td>
            </tr>
			<tr>
				<th></th>
				<td>
					<input name="submit" type="submit" value="提交" class="btn btn-primary span3">
					<input type="hidden" name="token" value="{$_W['token']}" />
				</td>
			</tr>
		</table>
	</form>
</div>

<script type="text/javascript">
        function check() {
            if($.trim($('#title').val()) == '') {
                message('没有输入商家名称.', '', 'error');
                return false;
            }
            return true;
        }
        </script>

<script type="text/javascript">
    kindeditor($('.richtext-clone'));
    kindeditorUploadBtn($('#btnlogo'));
</script>
<!--<script type="text/javascript" src="./source/modules/icard/template/js/map.js?v=4"></script>-->
<!--<script type="text/javascript">-->
    <!--$(function () {-->
        <!--var op = {-->
            <!--lat: "{if $reply['lat']!='0.0000000000' && !empty($reply['lat'])}{$reply['lat']}{else}23.367896{/if}",-->
            <!--lng: "{if $reply['lng']!='0.0000000000' && !empty($reply['lng'])}{$reply['lng']}{else}116.735049{/if}",-->
            <!--adr: "{if !empty($reply['place'])}{$reply['place']}{else}广东省汕头市龙湖区长平路韩江大厦{/if}"-->
        <!--}-->
        <!--baidu_map(op);-->
    <!--})-->
<!--</script>-->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<script type="text/javascript" src="http://api.map.baidu.com/getscript?v=1.4&ak=&services=&t=20140102035142"></script>
<script type="text/javascript">
    $(function(){
        $(".location").change(function(){
            bmap.searchMapByPCD();
        });
    });
new PCAS("location_p", "location_c", "location_a", location_p, location_c, location_a);
var bmap = {
    'option' : {
        'lock' : false,
        'container' : 'l-map',
        'infoWindow' : {'width' : 250, 'height' : 100, 'title' : ''},
        'point' : {'lng' : "{if $reply['lng']!='0.0000000000' && !empty($reply['lng'])}{$reply['lng']}{else}116.735049{/if}", 'lat' : "{if $reply['lat']!='0.0000000000' && !empty($reply['lat'])}{$reply['lat']}{else}23.367896{/if}"}
    },
    'init' : function(option) {
        var $this = this;
        $this.option = $.extend({},$this.option,option);

        $this.option.defaultPoint = new BMap.Point($this.option.point.lng, $this.option.point.lat);
        $this.bgeo = new BMap.Geocoder();
        $this.bmap = new BMap.Map($this.option.container);
        $this.bmap.centerAndZoom($this.option.defaultPoint, 15);
        $this.bmap.enableScrollWheelZoom();
        $this.bmap.enableDragging();
        $this.bmap.enableContinuousZoom();
        $this.bmap.addControl(new BMap.NavigationControl());
        $this.bmap.addControl(new BMap.OverviewMapControl());
        //添加标注
        $this.marker = new BMap.Marker($this.option.defaultPoint);
        $this.marker.setLabel(new BMap.Label('请您移动此标记，选择您的坐标！', {'offset':new BMap.Size(10,-20)}));
        $this.marker.enableDragging();
        $this.bmap.addOverlay($this.marker);
        //$this.marker.setAnimation(BMAP_ANIMATION_BOUNCE);
        $this.showPointValue($this.marker.getPosition());
        //拖动地图事件
        $this.bmap.addEventListener("dragging", function() {
            $this.setMarkerCenter();
            $this.option.lock = false;
        });
        //缩入地图事件
        $this.bmap.addEventListener("zoomend", function() {
            $this.setMarkerCenter();
            $this.option.lock = false;
        });
        //拖动标记事件
        $this.marker.addEventListener("dragend", function (e) {
            $this.showPointValue();
            $this.showAddress();
            $this.bmap.panTo(new BMap.Point(e.point.lng, e.point.lat));
            $this.option.lock = false;
            $this.marker.setAnimation(null);
        });
    },
    'searchMapByAddress' : function(address) {
        var $this = this;
        $this.bgeo.getPoint(address, function (point) {
            if (point) {
                $this.showPointValue();
                $this.showAddress();
                $this.bmap.panTo(point);
                $this.setMarkerCenter();
            }
        });
    },
    'searchMapByPCD' : function(address) {
        //alert($('#location_p').val()+$('#location_c').val()+$('#location_a').val());
        var $this = this;
        $this.option.lock = true;
        $this.searchMapByAddress($('#location_p').val()+$('#location_c').val()+$('#location_a').val());
    },
    'setMarkerCenter' : function() {
        var $this = this;
        var center = $this.bmap.getCenter();
        $this.marker.setPosition(new BMap.Point(center.lng, center.lat));
        $this.showPointValue();
        $this.showAddress();
    },
    'showPointValue' : function() {
        var $this = this;
        var point = $this.marker.getPosition();
        $('#lng').val(point.lng);
        $('#lat').val(point.lat);
    },
    'showAddress' : function() {
        var $this = this;
        var point = $this.marker.getPosition();
        $this.bgeo.getLocation(point, function (s) {
            if (s) {
                $('#place').val(s.address);
                if (!$this.option.lock) {
                    //cascdeInit(s.addressComponents.province,s.addressComponents.city,s.addressComponents.district);
                    new PCAS("location_p", "location_c", "location_a", s.addressComponents.province, s.addressComponents.city, s.addressComponents.district);
                }
            }
        });
    }
};
$(function(){
    var option = {};
    bmap.init(option);
});</script>
{template 'common/footer'}
